package com.sxf.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.sxf.dao.OptionDAO;
import com.sxf.domain.Option;
import com.sxf.mybatis.help.ExRowBounds;
import com.sxf.mybatis.help.QueryType;
import com.sxf.mybatis.page.Pagination;
import com.sxf.querybean.OptionQuery;
@Repository
public class OptionDAOImpl extends SuperDAOImpl implements OptionDAO {

	private static String STATEMENT_QUERY = "mybatis.xml.Option.query";

	@Override
	public Pagination<Option> queryPage(OptionQuery query) {
		return queryPageTemplate(STATEMENT_QUERY, query);
	}

	@Override
	public Option queryOne(OptionQuery query) {
		return st.selectOne(STATEMENT_QUERY, query);
	}

	@Override
	public List<Option> queryList(OptionQuery query) {
		return queryListTemplate(STATEMENT_QUERY, query);
	}

	@Override
	public Map<String, Object> queryMap(OptionQuery query) {
		Map<String, Object> map = st.selectMap(STATEMENT_QUERY, query, "name",
				new ExRowBounds(query.getOffset(), query.getLimit(),
						QueryType.OBJECT));
		// return (List<Option>) st.selectList(STATEMENT_QUERY, optionQuery,
		// new ExRowBounds(optionQuery.getOffset(),
		// optionQuery.getLimit(), QueryType.OBJECT));
		return map;
	}

	@Override
	public long queryNumber(OptionQuery query) {
		return queryNumberTemplate(STATEMENT_QUERY, query);
	}

	@Override
	public int insert(Option info) {
		if (info != null) {
			int i = st.insert("mybatis.xml.Option.insertSelective", info);
			return i;
		}
		return 0;
	}

	@Override
	public int update(Option info) {
		if (info != null) {
			return st.update("mybatis.xml.Option.updateByPrimaryKeySelective",
					info);
		}
		return 0;
	}

	@Override
	public int delete(Option info) {
		if (info != null) {
			return st.delete("mybatis.xml.Option.deleteByPrimaryKey", info);
		}
		return 0;
	}

}
